<?php

namespace App\Providers;

use JPush\Client;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Config\Repository;

/**
 * 极光推送服务
 *
 * Date: 2018/6/12
 * @author George
 * @package App\Providers
 */
class PushServiceProvider extends ServiceProvider
{
	/**
	 * 定义延迟加载服务提供者
	 *
	 * @var bool
	 * Date: 2018/6/12
	 * @author George
	 */
	protected $defer = true;

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
		$this->app->singleton('push', function ($app) {
			/**
			 * @var Repository $config
			 */
			$config = $app->config;
			return new Client($config->get('system.push.key'), $config->get('system.push.secret'), $config->get('system.push.path'));
		});
	}
}
